feat(proxy): outbound proxy support (http/https/socks4/socks5)#54
feat(proxy): outbound proxy support (http/https/socks4/socks5)#54feitianyul wants to merge 3 commits intoBiFangKNT:taurifrom
Conversation
feitianyul
commented
Jan 31, 2026
- 增加“网络代理”配置:支持 http/https/socks4/socks5,可选用户名/密码
- 代理对出站请求生效:更新检查 / 模型列表 / 测活 / 上游转发
- 默认关闭且不信任系统代理环境变量(避免被系统代理/环境变量影响)
- Python 依赖新增 PySocks 以支持 socks
添加网络代理功能的基础规范文档,包括需求说明、实施规划、数据模型、调研决策和任务清单。本次提交包含完整的开发框架,支持 HTTP/HTTPS/SOCKS4/SOCKS5 代理协议,确保配置单源存储和功能不回归。 主要变更包括: - 创建功能规范文档 spec.md,定义用户场景和验收标准 - 添加实施规划 plan.md,明确技术架构和分阶段实施策略 - 设计数据模型 data-model.md,定义代理配置实体结构 - 编写调研决策 research.md,记录技术选型和设计决策 - 生成任务清单 tasks.md,按用户故事分解开发任务 - 建立项目宪章 constitution.md,定义核心开发原则 - 添加 PowerShell 工具脚本,支持规范创建和检查流程 - 提供快速验证指南 quickstart.md,确保功能可测试
- 新增代理配置面板,支持 HTTP/HTTPS/SOCKS4/SOCKS5 代理类型 - 扩展配置存储结构以保存代理设置(启用状态、类型、地址、端口、认证信息) - 实现代理会话管理模块,自动应用于网络请求(代理转发、模型测活、更新检查等) - 添加 PySocks 依赖以支持 SOCKS 代理协议 - 更新 ESLint 配置忽略 archive 目录 - 完善 PowerShell 脚本以支持 tasks.md 检查
将 test_chat_completion 函数中的请求准备和响应日志处理逻辑提取为独立的 _prepare_chat_test_request 和 _log_chat_completion_response 函数,以提高代码可读性和可维护性。同时更新了任务清单和快速开始文档中的执行记录。
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
|
@codex 审查,中文回答 |
|
Codex Review: Didn't find any major issues. Breezy! ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
感谢 pr 现 base 已进入 release 封闭期,待发版后我将对此人工复查 如果你还有别的提议或疑问,欢迎交流! |
There was a problem hiding this comment.
需要在合并前处理以下问题:
-
必修:
python-src/modules/network/outbound_proxy.py当前在apply_outbound_proxy()中无条件执行session.trust_env = False。即使未启用出站代理,也会改变 requests 的默认行为(环境代理/证书相关环境变量均被忽略),存在行为回归风险。 -
必修:
python-src/mtga_app/__init__.py-> save_config 将可选的outbound_proxy_*字段整体传入,python-src/modules/services/config_service.py又无条件写入这些键;当字段未传入时可能把已有配置覆盖为
ull,兼容性有问题。 -
额外要求:请移除
.claude/与.specify/两个目录在本 PR 中的跟踪变更。当前仓库并未采用这些工具,且我方未对这些内容做过实际验证,不应随此功能改动一并引入。若确需保留,请拆分为独立 PR 并附验证说明。
BiFangKNT
left a comment
There was a problem hiding this comment.
补充行内阻塞意见(前两项):详见各代码行评论。第三项(移除 .claude/.specify)保持不变,沿用上一条 review。
| def apply_outbound_proxy(session: requests.Session) -> None: | ||
| settings = _load_settings() | ||
| enabled = settings.get("outbound_proxy_enabled") is True | ||
| session.trust_env = False |
There was a problem hiding this comment.
这里无条件 session.trust_env = False 会在未启用代理时也改变 requests 默认行为(环境代理/证书变量被忽略),属于潜在回归。建议仅在启用出站代理时设置,或保留默认值。
| "outbound_proxy_password", | ||
| ): | ||
| if key in outbound_proxy: | ||
| config_data[key] = outbound_proxy[key] |
There was a problem hiding this comment.
这里仅判断 key in outbound_proxy,当上游传入 None 时也会写入配置,可能覆盖已有值为 null。建议改为仅在值非 None 时写入,或在上游先过滤掉 None。